from tools_algorithm import *


class Solution:
    def maxPossibleScore(self, start: List[int], d: int) -> int:
        start.sort()

        def f(a):
            p = -inf
            for s in start:
                r = s + d
                if p + a > r:
                    return True
                p = max(s, p + a)
            return False

        return bisect_right(range(2000000001), False, key=f) - 1


s = Solution()
print(s.maxPossibleScore(start=[6, 0, 3], d=2))
print(s.maxPossibleScore(start=[2, 6, 13, 13], d=5))
